/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * <p>Project: app2022 - Demo
 * <p>Powered by webrx On 2022-01-18 10:14:21
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Demo {

    public static void main(String[] args) {
        try (FileInputStream fis = new FileInputStream("my.txt")) {
            //jdk 1.8 读取全部内容字节
            byte[] buf = new byte[fis.available()];
            fis.read(buf);
            System.out.println(new String(buf));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //jdk 1.8 nio java读取全部内容字节
        //import java.nio.file.Files;
        //import java.nio.file.Paths;
        try {
            byte[] buf = Files.readAllBytes(Paths.get("my.txt"));
            System.out.println(new String(buf));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static void hello(String[] args) {
        System.out.println("Hello World");
        System.out.println(System.getProperty("java.home"));
        System.out.println(System.getProperty("java.version"));
        System.out.println(System.getProperty("os.name"));
    }
}
